package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.domain.RoleResourceRelation;
import com.itheima.mapper.RoleResourceRelationMapper;
import com.itheima.service.IRoleResourceRelationService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 后台角色资源关系表 服务实现类
 * </p>
 *
 * @author fukeke
 * @since 2022-11-11
 */
@DubboService
public class RoleResourceRelationServiceImpl extends ServiceImpl<RoleResourceRelationMapper, RoleResourceRelation> implements IRoleResourceRelationService {

    @Autowired
    RoleResourceRelationMapper roleResourceRelationMapper;

    @Override
    public void deleteByRoleId(Long roleId) {
        LambdaQueryWrapper<RoleResourceRelation> qw=new LambdaQueryWrapper<>();
        qw.eq(RoleResourceRelation::getResourceId,roleId);
        roleResourceRelationMapper.delete(qw);
    }

    @Override
    public void saveRoleResourceRelation(RoleResourceRelation roleResourceRelation) {
        roleResourceRelationMapper.insert(roleResourceRelation);
    }

    @Override
    public List<RoleResourceRelation> findResourceByRoleId(Long roleId) {
        LambdaQueryWrapper<RoleResourceRelation>  qw=new LambdaQueryWrapper<>();
        qw.eq(RoleResourceRelation::getRoleId,roleId);
        return roleResourceRelationMapper.selectList(qw);
    }
}
